package com.sky.controller.admin;

import com.sky.constant.ShopStatusConstant;
import com.sky.result.Result;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RequiredArgsConstructor
@RestController("adminShopController")
@RequestMapping("/admin/shop")
public class ShopController {

    private final RedisTemplate<String, Object> redisTemplate;

    @PutMapping("/{status}")
    public Result<?> updateStatus(@PathVariable Integer status) {
        redisTemplate.opsForValue().set(ShopStatusConstant.BUSINESS_STOP_STATUS, status);
        return Result.success();
    }

    @GetMapping("/status")
    public Result<Integer> queryStatus() {
        Integer status = (Integer) redisTemplate.opsForValue().get(ShopStatusConstant.BUSINESS_STOP_STATUS);
        return Result.success(status == null ? 0 : status);
    }


}
